package com.phkj.qdh.ui.adapter.basetreenode

import com.phkj.qdh.bean.BaseInspectBean
import com.phkj.qdh.ui.dialog.BaseInspectTreeSelectDialog
import com.phkj.qdh.utils.node.BaseExpandNode
import com.phkj.qdh.utils.node.BaseNode
import com.phkj.qdh.utils.node.BaseNodeAdapter

class BaseTreeNodeAdapter(val baseInspectTreeSelectDialog: BaseInspectTreeSelectDialog) : BaseNodeAdapter() {
    init {
        addNodeProvider(BaseTreeHeadProvider(baseInspectTreeSelectDialog))
        addNodeProvider(BaseTreeContentProvider(baseInspectTreeSelectDialog))
    }

    override fun getItemType(data: List<BaseNode>, position: Int): Int {
        when (data[position]) {
            is BaseSortHeadNode -> {
                return 1
            }

            else -> {
                return 2
            }
        }
    }
}


data class BaseSortHeadNode(
    val headIndex: Int,
    val head: BaseInspectBean,
    val child: MutableList<BaseNode>?,
    var isSelected: Boolean = false
) : BaseExpandNode() {

    init {
        isExpanded = true
    }

    override val childNode: MutableList<BaseNode>?
        get() = child
}


data class BaseSortContentNode(
    val headIndex: Int,
    val childIndex: Int,
    val content: BaseInspectBean,
    var isSelected: Boolean = false
) : BaseExpandNode() {
    init {
        isExpanded = true
    }

    override val childNode: MutableList<BaseNode>?
        get() = null
}
